#ifndef __VSFUSB_UAC_H_INCLUDED__
#define __VSFUSB_UAC_H_INCLUDED__

#define UAC_VERSION_1						0x00
#define UAC_VERSION_2						0x20
#define UAC_VERSION_3						0x30

#define UAC_SUBCLASS_AUDIOCONTROL			0x01
#define UAC_SUBCLASS_AUDIOSTREAMING			0x02
#define UAC_SUBCLASS_MINISTREAMING			0x03

// SubTypes
enum
{
	// AC SubTypes
	UAC_HEADER = 1,
	UAC_INPUT_TERMINAL = 2,
	UAC_OUTPUT_TERMINAL = 3,
	UAC_MIXER_UNIT = 4,
	UAC_SELECTOR_UNIT = 5,
	UAC_FEATURE_UNIT = 6,
	UAC1_PROCESSING_UNIT = 7,
	UAC1_EXTENSION_UNIT = 8,

	// AS SubTypes
	UAC_AS_GENERAL = 1,
	UAC_FORMAT_TYPE = 2,
	UAC_FORMAT_SPECIFIC = 3,

	// Endpoint SubTypes
	UAC_EP_GENERAL = 1,
};

// Control Selectors
enum
{
	// Terminal
	UAC_TERM_COPY_PROTECT = 1,

	// Feature Unit
	UAC_FU_MUTE = 1,
	UAC_FU_VOLUME = 2,
	UAC_FU_BASS = 3,
	UAC_FU_MID = 4,
	UAC_FU_TREBLE = 5,
	UAC_FU_GRAPHIC_EQUALIZER = 6,
	UAC_FU_AUTOMAITC_GAIN = 7,
	UAC_FU_DELAY = 8,
	UAC_FU_BASS_BOOST = 9,
	UAC_FU_LOUDNESS = 10,

	// Up/Down-mix Processing Unit
	UAC_UD_ENABLE = 1,
	UAC_UD_MODE_SELECT = 2,

	// 3D Stereo Extender Processing Unit
	UAC_3D_ENABLE = 1,
	UAC_3D_SPACE = 2,

	// Reverberation Processing Unit
	UAC_REVERB_ENABLE = 1,
	UAC_REVERB_LEVEL = 2,
	UAC_REVERB_TIME = 3,
	UAC_REVERB_FEEDBACK = 4,

	// Chorus Processing Unit
	UAC_CHORUS_ENABLE = 1,
	UAC_CHORUS_LEVEL = 2,
	UAC_CHORUS_RATE = 3,
	UAC_CHORUS_DEPTH = 4,

	// Dynamic Range Compressor Unit
	UAC_DCR_ENABLE = 1,
	UAC_DCR_RATE = 2,
	UAC_DCR_MAXAMPL = 3,
	UAC_DCR_THREAHOLD = 4,
	UAC_DCR_ATTACK_TIME = 5,
	UAC_DCR_RELEASE_TIME = 6,

	// Extension Unit
	UAC_XU_ENABLE = 1,
};

// USB Terminal Types
#define UAC_UT_UNDEFINED					0x0100
#define UAC_UT_STREAMING					0x0101
#define UAC_UT_VENDOR_SPECIFIC				0x0102

// Input Terminal Types
#define UAC_IT_UNDEFINED					0x0200
#define UAC_IT_MICROPHONE					0x0201
#define UAC_IT_DESKTOP_MICROPHONE			0x0202
#define UAC_IT_PERSONAL_MICROPHONE			0x0203
#define UAC_IT_OMNI_DIRECTIONAL_MICROPHONE	0x0204
#define UAC_IT_MICROPHONE_ARRAY				0x0205
#define UAC_IT_PROCESSING_MICROPHONE_ARRAY	0x0206

// Output Terminal Types
#define UAC_OT_UNDEFINED					0x0300
#define UAC_OT_SPEAKER						0x0301
#define UAC_OT_HEADPHONES					0x0302
#define UAC_OT_HEAD_MOUNTED_DISPLAY_AUDIO	0x0303
#define UAC_OT_DESKTOP_SPEAKER				0x0304
#define UAC_OT_ROOM_SPEAKER					0x0305
#define UAC_OT_COMMUNICATION_SPEAKER		0x0306
#define UAC_OT_LOW_FREQ_EFFECTS_SPEAKER		0x0307

// Bi-directional Terminal Types
#define UAC_BT_UNDEFINED					0x0400
#define UAC_BT_HANDSET						0x0401
#define UAC_BT_HEADSET						0x0402
#define UAC_BT_SPEAKERPHONE					0x0403
#define UAC_BT_ECHO_SUPRESSING_SPEAKERPHONE	0x0404
#define UAC_BT_ECHO_CANCELING_SPEAKERPHONE	0x0405

// Telephony Terminal Types
#define UAC_TT_UNDEFINED					0x0500
#define UAC_TT_PHONE_LINE					0x0501
#define UAC_TT_TELEPHONE					0x0502
#define UAC_TT_DOWN_LINE_PHONE				0x0503

// eXternal Terminal Types
#define UAC_XT_UNDEFINED					0x0600
#define UAC_XT_ANALOG_CONNECTOR				0x0601
#define UAC_XT_DIGITAL_AUDIO_INTERFACE		0x0602
#define UAC_XT_LINE_CONNECTOR				0x0603
#define UAC_XT_LEGACY_AUDIO_CONNECTOR		0x0604
#define UAC_XT_SPDIF_INTERFACE				0x0605
#define UAC_XT_1394_DA_STREAM				0x0606
#define UAC_XT_1394_DV_STREAM_SOUNDTRACK	0x0607

// Embedded Function Terminal Types
#define UAC_ET_UNDEFINED					0x0700
#define UAC_ET_LEVEL_CALI_NOISE_SOURCE		0x0701
#define UAC_ET_EQUALIZATION_NOSIZE			0x0702
#define UAC_ET_CD_PLAYER					0x0703
#define UAC_ET_DAT							0x0704
#define UAC_ET_DCC							0x0705
#define UAC_ET_MINIDISK						0x0706
#define UAC_ET_ANALOG_TAPE					0x0707
#define UAC_ET_PHONOGRAPH					0x0708
#define UAC_ET_VCR_AUDIO					0x0709
#define UAC_ET_VIDEO_DISC_AUDIO				0x070A
#define UAC_ET_DVD_AUDIO					0x070B
#define UAC_ET_TV_TUNER_AUDIO				0x070C
#define UAC_ET_SATELLITE_RECEIVER_AUDIO		0x070D
#define UAC_ET_CABLE_TUNER_AUDIO			0x070E
#define UAC_ET_DSS_AUDIO					0x070F
#define UAC_ET_RADIO_RECEIVER				0x0110
#define UAC_ET_RADIO_TRANSMITTER			0x0711
#define UAC_ET_MULTI_TRACK_RECORDER			0x0712
#define UAC_ET_SYNTHESIZER					0x0713

PACKED_HEAD struct PACKED_MID uac1_ac_header_descriptor
{
	struct usb_cs_header_t header;

	uint16_t bcdUAC;
	uint16_t wTotalLength;
	uint8_t bInCollection;
	uint8_t baInterfaceNr[0];
}; PACKED_TAIL

PACKED_HEAD struct PACKED_MID uac_input_terminal_descriptor
{
	struct usb_cs_header_t header;

	uint8_t bTerminalID;
	uint16_t wTerminalType;
	uint8_t bAssocTerminal;
	uint8_t bNuChannels;
	uint16_t wChannelConfig;
	uint8_t iChnnelNames;
	uint8_t iTerminal;
}; PACKED_TAIL

PACKED_HEAD struct PACKED_MID uac_output_terminal_descriptor
{
	struct usb_cs_header_t header;

	uint8_t bTerminalID;
	uint16_t wTerminalType;
	uint8_t bAssocTerminal;
	uint8_t bSourceID;
	uint8_t iTerminal;
}; PACKED_TAIL

PACKED_HEAD struct PACKED_MID uac_mixer_unit_descriptor_h
{
	struct usb_cs_header_t header;

	uint8_t bUnitID;
	uint8_t bNrInPins;
	uint8_t baSourceID[0];
}; PACKED_TAIL

PACKED_HEAD struct PACKED_MID uac_mixer_unit_descriptor_t
{
	uint8_t bNrChannels;
	uint16_t wChannelConfig;
	uint8_t iChannelNames;
	uint8_t bmControls[0];
}; PACKED_TAIL

PACKED_HEAD struct PACKED_MID uac_selector_unit_descriptor
{
	struct usb_cs_header_t header;

	uint8_t bUnitID;
	uint8_t bNrInPins;
	uint8_t baSourceID[0];
}; PACKED_TAIL

PACKED_HEAD struct PACKED_MID uac_feature_unit_descriptor
{
	struct usb_cs_header_t header;

	uint8_t bUnitID;
	uint8_t bSourceID;
	uint8_t bControlSize;
	uint8_t bmaControls[0];
}; PACKED_TAIL

PACKED_HEAD struct PACKED_MID uac_processing_unit_descriptor_h
{
	struct usb_cs_header_t header;

	uint8_t bUnitID;
	uint16_t wProcessType;
	uint8_t bNrInPins;
	uint8_t baSourceID[0];
}; PACKED_TAIL

PACKED_HEAD struct PACKED_MID uac_processing_unit_descriptor_m
{
	uint8_t bNrChannels;
	uint16_t wChannelConfig;
	uint8_t iChannelNames;
	uint8_t bControlSize;
	uint8_t bmaControls[0];
}; PACKED_TAIL

PACKED_HEAD struct PACKED_MID uac_processing_unit_descriptor_t
{
	uint8_t iProcessing;
}; PACKED_TAIL

#endif		// __VSFUSB_UAC_H_INCLUDED__
